using System;
using System.Collections.Generic;
using System.Web.UI;
using Telerik.Sitefinity.Web.UI;
using Telerik.Sitefinity.Web.UI.ControlDesign;

namespace SocialWidgetsContrib.Widgets.Socialbar
{
    public class SocialShareBarDesigner : ControlDesignerBase
    {
        private string _layoutTemplatePath = "SocialWidgetsContrib.Resources.Designers.SocialShareBarDesigner.ascx";

        private string _scriptPath = "SocialWidgetsContrib.Resources.Scripts.SocialShareBarDesigner.js";

        protected override HtmlTextWriterTag TagKey
        {
            get { return HtmlTextWriterTag.Div; }
        }

        //public override string LayoutTemplatePath
        //{
        //    get
        //    {
        //        return _layoutTemplatePath;
        //    }
        //    set
        //    {
        //        _layoutTemplatePath = value;
        //    }
        //}

        //protected override string LayoutTemplatePath
        //{
        //    get { return _layoutTemplatePath; }
        //    //set { _layoutTemplatePath = value; }
        //}

        public string DesignerScriptPath
        {
            get { return _scriptPath; }
            set { _scriptPath = value; }
        }

        protected override string LayoutTemplateName
        {
            get { return _layoutTemplatePath; }
        }

        protected override void InitializeControls(GenericContainer container)
        {
            base.DesignerMode = ControlDesignerModes.Simple;
        }


        public override IEnumerable<ScriptReference> GetScriptReferences()
        {
            var res = new List<ScriptReference>(base.GetScriptReferences());
            var assemblyName = this.GetType().Assembly.GetName().ToString();

            res.Add(new ScriptReference(_scriptPath, assemblyName));
            return res.ToArray();

            //var scripts = base.GetScriptReferences() as List<ScriptReference>;
            //if (scripts == null) return base.GetScriptReferences();

            //scripts.Add(new ScriptReference(DesignerScriptPath));
            //return scripts.ToArray();
        }
    }
}